package com.zt.student.controller;

import com.zt.common.Do.OriginStudentDO;
import com.zt.common.pojo.common.JsonResult;
import com.zt.student.dto.UpdateOriginStuDTO;
import com.zt.student.service.OriginStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * description:
 * author:zt
 * date:2022-01-09
 */
@RestController
@CrossOrigin
@RequestMapping("originStudent")
@Api("学校学生信息模块")
public class OriginStudentController {

    @Autowired
    private OriginStudentService originStudentService;

    @PostMapping("updatePwd")
    @ApiOperation("修改学生原始信息密码")
    public JsonResult updatePwd(@RequestBody UpdateOriginStuDTO updateOriginStuDTO, HttpServletRequest request){
        originStudentService.updatePwd(updateOriginStuDTO.getOldPwd(), updateOriginStuDTO.getNewPwd(), request);
        return JsonResult.success();
    }

    @GetMapping("getInfo")
    @ApiOperation("获取学生学籍信息")
    public JsonResult<OriginStudentDO> getInfoById(HttpServletRequest request){
        OriginStudentDO info = originStudentService.getInfoById(request);
        return JsonResult.success(info);
    }
}
